package com.lzm.dto;

import com.lzm.domain.SuccessKilled;
import com.lzm.enums.SeckillStatEnum;

/**
 * 封装执行秒杀后的结果:是否秒杀成功
 */
public class SeckillExecution {

    private Long seckillId;

    //秒杀执行结果的状态
    private int code;

    //状态的明文标识
    private String msg;

    //当秒杀成功时，需要传递秒杀成功的对象回去
    private SuccessKilled successKilled;

    //秒杀成功返回所有信息
    public SeckillExecution(Long seckillId, SeckillStatEnum statEnum, SuccessKilled successKilled) {
        this.seckillId = seckillId;
        this.code = statEnum.getCode();
        this.msg = statEnum.getDescribe();
        this.successKilled = successKilled;
    }

    //秒杀失败
    public SeckillExecution(Long seckillId, SeckillStatEnum statEnum) {
        this.seckillId = seckillId;
        this.code = statEnum.getCode();
        this.msg = statEnum.getDescribe();
    }

    public long getSeckillId() {
        return seckillId;
    }

    public void setSeckillId(Long seckillId) {
        this.seckillId = seckillId;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public SuccessKilled getSuccessKilled() {
        return successKilled;
    }

    public void setSuccessKilled(SuccessKilled successKilled) {

        this.successKilled = successKilled;
    }

    @Override
    public String toString() {
        return "SeckillExecution{" +
                "seckillId=" + seckillId +
                ", code=" + code +
                ", msg='" + msg + '\'' +
                ", successKilled=" + successKilled +
                '}';
    }
}
